#include "../head/client.h"
#include "../head/transfer.h"
#include <mysql/mysql.h>
#define MMAP_THRESHOLD (100*1024*1024)  

int reiceive(int netfd){
    TLVMsg msg;
    printf("服务端:\n"); 
    recvfd(netfd,&msg);
    printf("你好\n");
    /* MYSQL *conn=mysql_init(NULL); */
    /* if(msg.type==CMD_PUTS){ */
    /*     mysql_database(conn); */
    /* } */
    //printf("%s\n",msg.value);
    /* printf("msg.type=%d\n",msg.type); */ 
    /* printf("msg.valu=%s\n",msg.value); */
    /* printf("msg.value_len =%d\n",msg.value_len); */
    /* printf("服务端:\n"); */ 
    int ret=msg.type;
    switch (ret){    
    case CMD_INVALID:    //无效
        printf("%s\n",msg.value);
        break;
    case CMD_CD:       //切换目录
        printf("%s\n",msg.value) ; 
        break;
    case CMD_LS:      //列出目录下文件
        printf("%s\n",msg.value);
        break;
    case CMD_PUTS://上传文件 
        transfile_client(msg.value,netfd);
        recvfd(netfd,&msg);
        printf("%s\n",msg.value);
        break;
    case CMD_GETS:   //下载文件
        //recvfile(netfd);
        recvfile_client(netfd);
        break;
    case CMD_REMOVE:   //删除文件
        printf("%s\n",msg.value);
        break;
    case CMD_PWD:     //显示路径
        printf("%s\n",msg.value);
        break;
    case CMD_MKDIR:   //创建目录
        printf("%s\n",msg.value);
        break;
    case CMD_LOGIN:     //登录
        enter(netfd);
        //clicent_login_in(char *user,char *passwd ,int sockfd)
        break;
    case CMD_LOGOUT:   //退出登录
        break;
    case CMD_QUIT:    //退出
        printf("退出成功，请重新打开软件\n");
        exit(0);
    case CMD_RMDIR:   //删除目录
        printf("%s\n",msg.value);
        break;
    case CMD_RESUME:
        //recvfile(netfd);
        break;
    case CMD_SIGN:   //注册
        register_account(netfd);
        break;
    /* case CMD_CANCEL:   //注销 */
    /*     printf("%s\n",msg.value); */
    /*     break; */

    }
    return 0;
}

